package com.ophiux.rocket.controller;

import com.ophiux.rocket.channel.MyChannel;
import com.ophiux.rocket.dto.UserEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CompletableFuture;

@Slf4j
@RestController
public class MQController {
    @Autowired
    private MyChannel myChannel;

    @GetMapping("/test")
    public void test() {
        UserEntity userEntity = new UserEntity("hello", "pass");
        boolean send = myChannel.output().send(MessageBuilder.withPayload(userEntity).build());
        log.info("发送消息:{},结果:{}", userEntity.toString(), send);
    }
}
